/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


// validate About US
function validate_Add_About_Us()
{
    if(document.all)
    {
        var aboutUsTerm = document.all.Add_About_Us.about_us_term;
        var aboutUsRank =  document.all.Add_About_Us.about_us_rank;
    }
    else
    {
        var aboutUsTerm = document.Add_About_Us.about_us_term;
        var aboutUsRank =  document.Add_About_Us.about_us_rank;
    }

    var numbers=/^[0-9]+$/;

    if (aboutUsTerm.value.trim()=="")
    {
        alert ( "Please Enter Term" );
        aboutUsTerm.focus();
        return false;
    }
    if(aboutUsRank.value.trim()=="")
    {
        alert ("Please Enter Rank");
        aboutUsRank.focus();
        return false;
    }
    if(!aboutUsRank.value.trim().match(numbers)||aboutUsRank.value.trim()>1000)
    {
        alert ("Please Enter Valid Term Rank" );
        aboutUsRank.focus();
        return false;
    }
    return true;
}

function validate_Update_About_Us()
{
    if(document.all)
    {
        var aboutUsTerm = document.all.Update_About_Us.about_us_term;
        var aboutUsRank =  document.all.Update_About_Us.about_us_rank;
    }
    else
    {
        var aboutUsTerm = document.Update_About_Us.about_us_term;
        var aboutUsRank =  document.Update_About_Us.about_us_rank;
    }

    var numbers=/^[0-9]+$/;

    if (aboutUsTerm.value.trim()=="")
    {
        alert ( "Please Enter Term" );
        aboutUsTerm.focus();
        return false;
    }
    if(aboutUsRank.value.trim()=="")
    {
        alert ("Please Enter Rank");
        aboutUsRank.focus();
        return false;
    }
    if(!aboutUsRank.value.trim().match(numbers)||aboutUsRank.value.trim()>1000)
    {
        alert ("Please Enter Valid Term Rank" );
        aboutUsRank.focus();
        return false;
    }
    return true;
}

function delete_About_Us()
{

    var answer=confirm("Are you sure you want to delete this term?");
    if (answer)
        return true;
    else
        return false;
}

// Validate Career Category
function validate_Add_Career_Category()
{
    if(document.all)
    {
        var careerCategoryTitle = document.all.Add_Career_Category.career_category_title;
        var careerCategoryRank =  document.all.Add_Career_Category.career_category_rank;
    }
    else
    {
        var careerCategoryTitle = document.Add_Career_Category.career_category_title;
        var careerCategoryRank =  document.Add_Career_Category.career_category_rank;
    }

    var numbers=/^[0-9]+$/;

    if (careerCategoryTitle.value.trim()=="")
    {
        alert ( "Please Enter Title" );
        careerCategoryTitle.focus();
        return false;
    }
    if(careerCategoryRank.value.trim()=="")
    {
        alert ("Please Enter Rank");
        careerCategoryRank.focus();
        return false;
    }
    if(!careerCategoryRank.value.trim().match(numbers)||careerCategoryRank.value.trim()>1000)
    {
        alert ("Please Enter Valid Category Rank" );
        careerCategoryRank.focus();
        return false;
    }
    return true;
}

function validate_Update_Career_Category()
{
    if(document.all)
    {
        var careerCategoryTitle = document.all.Update_Career_Category.career_category_title;
        var careerCategoryRank =  document.all.Update_Career_Category.career_category_rank;
    }
    else
    {
        var careerCategoryTitle = document.Update_Career_Category.career_category_title;
        var careerCategoryRank =  document.Update_Career_Category.career_category_rank;
    }

    var numbers=/^[0-9]+$/;

    if (careerCategoryTitle.value.trim()=="")
    {
        alert ( "Please Enter Title" );
        careerCategoryTitle.focus();
        return false;
    }
    if(careerCategoryRank.value.trim()=="")
    {
        alert ("Please Enter Rank");
        careerCategoryRank.focus();
        return false;
    }
    if(!careerCategoryRank.value.trim().match(numbers)||careerCategoryRank.value.trim()>1000)
    {
        alert ("Please Enter Valid Category Rank" );
        careerCategoryRank.focus();
        return false;
    }

    return true;
}

function delete_Career_Category()
{

    var answer=confirm("Are you sure you want to delete this category?");
    if (answer)
        return true;
    else
        return false;
}

// Validate Cities
function validate_Cities()
{}

// Validate Countries
function validate_Countries()
{}

// Validate Customer
function validate_Customer()
{}

// Validate Department
function validate_Department()
{}

// Validate Grade
function validate_Grade()
{}

// Validate Institute
function validate_Institute()
{}

// Validate Level
function validate_Level()
{
    var numbers=/^[0-9]+$/;
    var level_name= document.Add_Level.level_name;
    var level_rank= document.Add_Level.level_rank;

    if(level_name.value.trim()=="")
    {
        alert ( "Please enter Level Name" );
        level_name.focus();
        return false;
    }
    if(level_name.value.trim().length>50)
    {
        alert ( "the name is too large" );
        level_name.focus();
        return false;
    }
    if(level_rank.value.trim()=="")
    {
        alert ( "Please enter Level Rank" );
        level_rank.focus();
        return false;
    }
    if(!level_rank.value.trim().match(numbers)||level_rank.value.trim()>1000)
    {
        alert ("Please Enter Valid level Level Rank " );
        level_rank.focus();
        return false;
    }
    return true;
}

// Validate News
function validate_Add_News()
{
    if(document.all)
    {
        var newsCategoryId = document.all.Add_News.news_category_id;
        var newsTitle = document.all.Add_News.news_title;
        var newsShortDescription =  document.all.Add_News.news_short_description;
        var newsLogo =  document.all.Add_News.news_logo;
        var newsImage =  document.all.Add_News.news_image;
    }
    else
    {
        var newsCategoryId = document.Add_News.news_category_id;
        var newsTitle = document.Add_News.news_title;
        var newsShortDescription =  document.Add_News.news_short_description;
        var newsLogo =  document.Add_News.news_logo;
        var newsImage =  document.Add_News.news_image;
    }

    if (newsCategoryId.options[newsCategoryId.selectedIndex].value=='Please select one')
    {
        alert ( "Please Select News Category" );
        newsCategoryId.focus();
        return false;
    }

    if (newsTitle.value.trim()=="")
    {
        alert ( "Please Enter News Title" );
        newsTitle.focus();
        return false;
    }

    if (newsShortDescription.value.trim()=="")
    {
        alert ( "Please Enter Short Description" );
        newsShortDescription.focus();
        return false;
    }

    if(newsLogo.value.trim()=="")
    {
        alert ("Please Upload News Logo");
        return false;
    }

    if(newsImage.value.trim()=="")
    {
        alert ("Please Upload News Image");
        return false;
    }

    return true;
}

function validate_Update_News()
{


    if(document.all)
    {
        var newsCategoryId =document.all.Update_News.elements["news_category_id"];
        var newsTitle = document.all.Update_News.news_title;
        var newsShortDescription =  document.all.Update_News.news_short_description;
        var newsLogo =  document.all.Update_News.news_logo;
        var newsImage =  document.all.Update_News.news_image;
    }
    else
    {
        var newsCategoryId =document.Update_News.elements["news_category_id"];
        var newsTitle = document.Update_News.news_title;
        var newsShortDescription =  document.Update_News.news_short_description;
        var newsLogo =  document.Update_News.news_logo;
        var newsImage =  document.Update_News.news_image;
    }

    if (newsCategoryId.options[newsCategoryId.selectedIndex].value=='Please select one')
    {
        alert ( "Please Select News Category" );
        newsCategoryId.focus();
        return false;
    }

    if (newsTitle.value.trim()=="")
    {
        alert ( "Please Enter News Title" );
        newsTitle.focus();
        return false;
    }

    if (newsShortDescription.value.trim()=="")
    {
        alert ( "Please Enter Short Description" );
        newsShortDescription.focus();
        return false;
    }

    if(newsLogo.value.trim()=="")
    {
        alert ("Please Upload News Logo");
        return false;
    }

    if(newsImage.value.trim()=="")
    {
        alert ("Please Upload News Image");
        return false;
    }

    return true;
}

function delete_News()
{

    var answer=confirm("Are you sure you want to delete this news?");
    if (answer)
        return true;
    else
        return false;
}

// Validate News Category
function validate_Add_News_Category()
{
    if(document.all)
    {
        var newsCategoryTitle = document.all.Add_News_Category.news_category_title;
        var newsCategoryRank =  document.all.Add_News_Category.news_category_rank;
        var period = document.all.Add_News_Category.period;
        var comments = document.all.Add_News_Category.comments;
    }
    else
    {
        var newsCategoryTitle = document.Add_News_Category.news_category_title;
        var newsCategoryRank =  document.Add_News_Category.news_category_rank;
        var period = document.Add_News_Category.period;
        var comments = document.Add_News_Category.comments;
    }

    var numbers=/^[0-9]+$/;

    if (newsCategoryTitle.value.trim()=="")
    {
        alert ( "Please Enter Category Title" );
        newsCategoryTitle.focus();
        return false;
    }

    if(newsCategoryRank.value.trim()=="")
    {
        alert ("Please Enter Rank");
        newsCategoryRank.focus();
        return false;
    }

    if(!newsCategoryRank.value.trim().match(numbers)||newsCategoryRank.value.trim()>1000)
    {
        alert ("Please Enter Valid Category Rank" );
        newsCategoryRank.focus();
        return false;
    }

    if (period.value.trim()=="")
    {
        alert ( "Please Enter Period" );
        period.focus();
        return false;
    }

    if (comments.value.trim()=="")
    {
        alert ( "Please Enter Comments" );
        comments.focus();
        return false;
    }
    return true;
}

function validate_Update_News_Category()
{
    if(document.all)
    {
        var newsCategoryTitle = document.all.Add_News_Category.news_category_title;
        var newsCategoryRank =  document.all.Add_News_Category.news_category_rank;
        var period = document.all.Add_News_Category.period;
        var comments = document.all.Add_News_Category.comments;
    }
    else
    {
        var newsCategoryTitle = document.Add_News_Category.news_category_title;
        var newsCategoryRank =  document.Add_News_Category.news_category_rank;
        var period = document.Add_News_Category.period;
        var comments = document.Add_News_Category.comments;
    }

    var numbers=/^[0-9]+$/;

    if (newsCategoryTitle.value.trim()=="")
    {
        alert ( "Please Enter Category Title" );
        newsCategoryTitle.focus();
        return false;
    }

    if(newsCategoryRank.value.trim()=="")
    {
        alert ("Please Enter Rank");
        newsCategoryRank.focus();
        return false;
    }

    if(!newsCategoryRank.value.trim().match(numbers)||newsCategoryRank.value.trim()>1000)
    {
        alert ("Please Enter Valid Category Rank" );
        newsCategoryRank.focus();
        return false;
    }

    if (period.value.trim()=="")
    {
        alert ( "Please Enter Period" );
        period.focus();
        return false;
    }

    if (comments.value.trim()=="")
    {
        alert ( "Please Enter Comments" );
        comments.focus();
        return false;
    }
    return true;
}

function delete_News_Category()
{

    var answer=confirm("Are you sure you want to delete this category?");
    if (answer)
        return true;
    else
        return false;
}
// Validate Partner
function validate_Partner()
{}

// Validate Product
function validate_Add_Product()
{
    if(document.all)
    {
        var productName = document.all.Add_Product.product_name;
        var productShortDescription =  document.all.Add_Product.product_short_description;
        var productLogo =  document.all.Add_Product.product_logo;
        var productImage =  document.all.Add_Product.product_image;
    }
    else
    {
        var productName = document.Add_Product.product_name;
        var productShortDescription =  document.Add_Product.product_short_description;
        var productLogo =  document.Add_Product.product_logo;
        var productImage =  document.Add_Product.product_image;
    }

    if (productName.value.trim()=="")
    {
        alert ( "Please Enter Product Name" );
        productName.focus();
        return false;
    }

    if (productShortDescription.value.trim()=="")
    {
        alert ( "Please Enter Short Description" );
        productShortDescription.focus();
        return false;
    }

    if(productLogo.value.trim()=="")
    {
        alert ("Please Upload Product Logo");
        return false;
    }

    if(productImage.value.trim()=="")
    {
        alert ("Please Upload Product Image");
        return false;
    }

    return true;
}

function validate_Update_Product()
{
    if(document.all)
    {
        var productName = document.all.Update_Product.product_name;
        var productShortDescription =  document.all.Update_Product.product_short_description;
        var productLogo =  document.all.Update_Product.product_logo;
        var productImage =  document.all.Update_Product.product_image;
    }
    else
    {
        var productName = document.Update_Product.product_name;
        var productShortDescription =  document.Update_Product.product_short_description;
        var productLogo =  document.Update_Product.product_logo;
        var productImage =  document.Update_Product.product_image;
    }

    if (productName.value.trim()=="")
    {
        alert ( "Please Enter Product Name" );
        productName.focus();
        return false;
    }

    if (productShortDescription.value.trim()=="")
    {
        alert ( "Please Enter Short Description" );
        productShortDescription.focus();
        return false;
    }

    if(productLogo.value.trim()=="")
    {
        alert ("Please Upload Product Logo");
        return false;
    }

    if(productImage.value.trim()=="")
    {
        alert ("Please Upload Product Image");
        return false;
    }

    return true;
}

function delete_Product()
{

    var answer=confirm("Are you sure you want to delete this product?");
    if (answer)
        return true;
    else
        return false;
}

// Validate Service
function validate_Add_Service()
{
    if(document.all)
    {
        var serviceName = document.all.Add_Service.service_name;
        var serviceShortDescription =  document.all.Add_Service.service_short_description;
        var serviceLogo =  document.all.Add_Service.service_logo;
        var serviceImage =  document.all.Add_Service.service_image;
    }
    else
    {
        var serviceName = document.Add_Service.service_name;
        var serviceShortDescription =  document.Add_Service.service_short_description;
        var serviceLogo =  document.Add_Service.service_logo;
        var serviceImage =  document.Add_Service.service_image;
    }

    if (serviceName.value.trim()=="")
    {
        alert ( "Please Enter Service Name" );
        serviceName.focus();
        return false;
    }

    if (serviceShortDescription.value.trim()=="")
    {
        alert ( "Please Enter Short Description" );
        serviceShortDescription.focus();
        return false;
    }

    if(serviceLogo.value.trim()=="")
    {
        alert ("Please Upload Service Logo");
        return false;
    }

    if(serviceImage.value.trim()=="")
    {
        alert ("Please Upload Service Image");
        return false;
    }

    return true;
}

function validate_Update_Service()
{
    if(document.all)
    {
        var serviceName = document.all.Update_Service.service_name;
        var serviceShortDescription =  document.all.Update_Service.service_short_description;
        var serviceLogo =  document.all.Update_Service.service_logo;
        var serviceImage =  document.all.Update_Service.service_image;
    }
    else
    {
        var serviceName = document.Update_Service.service_name;
        var serviceShortDescription =  document.Update_Service.service_short_description;
        var serviceLogo =  document.Update_Service.service_logo;
        var serviceImage =  document.Update_Service.service_image;
    }

    if (serviceName.value.trim()=="")
    {
        alert ( "Please Enter Service Name" );
        serviceName.focus();
        return false;
    }

    if (serviceShortDescription.value.trim()=="")
    {
        alert ( "Please Enter Short Description" );
        serviceShortDescription.focus();
        return false;
    }

    if(serviceLogo.value.trim()=="")
    {
        alert ("Please Upload Service Logo");
        return false;
    }

    if(serviceImage.value.trim()=="")
    {
        alert ("Please Upload Service Image");
        return false;
    }

    return true;
}

function delete_Service()
{

    var answer=confirm("Are you sure you want to delete this service?");
    if (answer)
        return true;
    else
        return false;
}

// Validate Study Field
function validate_Study_Field()
{}

// Validate Supplier Field
function validate_Supplier_Field()
{}

// Validate Vacancy
function validate_Vacancy()
{}

// Validate Contact Us
function  validate_Contact_Us()
{
    var check_name =document.contact.name;
    var check_phone =document.contact.phone;
    var check_Email=document.contact.email;
    var check_sup=document.contact.subject;
    var check_message =document.contact.message;
    var numbers=/^[0-9]+$/;

    check_name.value=check_name.value.trim();
    check_phone.value=check_phone.value.trim();
    check_Email.value=check_Email.value.trim();
    check_sup.value=check_sup.value.trim();
    check_message.value=check_message.value.trim();

    if (check_name.value.trim()=="")
    {
        alert ( "Please Enter Your Name" );
        check_name.focus();
        return false;
    }
    if (errorcheck(check_name.value.trim())==false)
    {
        alert("Please Enter Valid Character \" ");
        check_name.focus();
        return false;
    }

    if(check_name.value.trim().length>45)
    {
        alert ( "Name is too long" );

        check_name.focus();
        return false;

    }

    if (check_phone.value.trim()=="")
    {
        alert ( "Please Enter Your Phone Number" );


        check_phone.focus();
        return false;
    }
    if(!check_phone.value.trim().match(numbers))
    {
        alert ( "Please Enter Valid Phone Number" );

        check_phone.focus();
        return false;
    }
    if(check_phone.value.trim().length>20)
    {
        alert ("Phone Number is too long" );
        check_phone.focus();
        return false;
    }

    if (check_Email.value.trim()=="")
    {
        alert ( "Please Enter Your Email" );
        check_Email.focus();
        return false;
    }
    if (errorcheck(check_Email.value.trim())==false)
    {
        alert("Please Enter Valid Character \" ");
        check_Email.focus();
        return false;
    }


    if (echeck(check_Email.value.trim())==false)
    {
        check_Email.focus();
        return false;
    }
    if (check_Email.value.trim().length>100)
    {
        alert("Email is too long");
        check_Email.focus();
        return false;
    }


    if(check_sup.value.trim()=="")
    {
        alert ( "Please Enter Message Subject " );

        check_sup.focus();
        return false;

    }
    if (errorcheck(check_sup.value.trim())==false)
    {
        alert("Please Enter Valid Character \" ");
        check_sup.focus();
        return false;
    }
    if(check_sup.value.trim().length>100)
    {
        alert ( "Subject is too long" );

        check_sup.focus();
        return false;

    }
    if(check_message.value.trim()=="")
    {
        alert ( "Please Enter Your Message  " );

        check_message.focus();
        return false;
    }
    if (errorcheck(check_message.value.trim())==false)
    {
        alert("Please Enter Valid Character \" ");
        check_message.focus();
        return false;
    }
    return true;
}

function echeck(str)
{
    var at="@"
    var dot="."
    var lat=str.indexOf(at)
    var lstr=str.length
    var ldot=str.indexOf(dot)
    if (str.indexOf(at)==-1)
    {
        alert("Please Enter Valid E-mail")
        return false
    }

    if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
        alert("Please Enter Valid E-mail")
        return false
    }

    if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
        alert("Please Enter Valid E-mail")
        return false
    }

    if (str.indexOf(at,(lat+1))!=-1){
        alert("Please Enter Valid E-mail")
        return false
    }

    if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
        alert("Please Enter Valid E-mail")
        return false
    }

    if (str.indexOf(dot,(lat+2))==-1){
        alert("Please Enter Valid E-mailD")
        return false
    }

    if (str.indexOf(" ")!=-1){
        alert("Please Enter Valid E-mail")
        return false
    }

    return true
}

String.prototype.trim = function () {
    return this.replace(/^\s*/, "").replace(/\s*$/, "");
}

function errorcheck(str)
{
    if(str.indexOf("\"")==-1)
    {

        return true;
    }


    return false;
}



// Validate Add Application
function  validate_Add_Application_Personal()
{
    if(document.all)
    {
        var gender = document.all.Add_Applicant.elements["gender"];
        var firstName = document.all.Add_Applicant.first_name;
        var middleName =document.all.Add_Applicant.middle_name;
        var lastName =document.all.Add_Applicant.last_name;
        var birthOfDate = document.all.Add_Applicant.date_of_birth;
        var placeOfBirth = document.all.Add_Applicant.elements["place_of_birth"];
        var maritalStatus = document.all.Add_Applicant.elements["maritaly_status"];
        var militaryStatus = document.all.Add_Applicant.elements["military_status"];
        var numberOfChildren = document.all.Add_Applicant.elements["no_of_children"];
    }
    else
    {
        var gender = document.Add_Applicant.elements["gender"];
        var firstName = document.Add_Applicant.first_name;
        var middleName =document.Add_Applicant.middle_name;
        var lastName =document.Add_Applicant.last_name;
        var birthOfDate = document.Add_Applicant.date_of_birth;
        var placeOfBirth = document.Add_Applicant.elements["place_of_birth"];
        var maritalStatus = document.Add_Applicant.elements["maritaly_status"];
        var militaryStatus = document.Add_Applicant.elements["military_status"];
        var numberOfChildren = document.Add_Applicant.elements["no_of_children"];
    }

    var alpha=/^[a-zA-Z]+$/;
    var date=/^(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\d\d$/;


    if (gender.value=="-1")
    {
        alert ( "Please Specify your Gender" );
        gender.focuse();
        return false;
    }

    if (firstName.value=="")
    {
        alert ( "Please Enter Your First Name " );
        firstName.focus();
        return false;
    }

    if (!firstName.value.match(alpha))
    {
        alert ( "Please Enter Correct Name" );
        firstName.focus();
        return false;
    }

    if (errorcheck(firstName.value)==false)
    {
        alert("Your First Name has Invalid Characters");
        firstName.focus();
        return false;
    }

    if (firstName.value.length>45)
    {
        alert("Name is too long");
        firstName.focus();
        return false;
    }

    if (middleName.value=="")
    {
        alert ( "Please Enter Your Middle Name " );
        middleName.focus();
        return false;
    }


    if (!middleName.value.match(alpha))
    {
        alert ( "Please Enter Correct Name" );
        middleName.focus();
        return false;
    }
    if (errorcheck(middleName.value)==false)
    {
        alert("Your Middle Name has Invalid Characters ");
        middleName.focus();
        return false;
    }

    if (middleName.value.length>45)
    {
        alert("Name is too long");
        middleName.focus();
        return false;
    }


    if (lastName.value=="")
    {
        alert ( "Please Enter Your Last Name " );
        lastName.focus();
        return false;
    }


    if (!lastName.value.match(alpha))
    {
        alert ( "Please Enter Correct Name" );
        lastName.focus();
        return false;
    }

    if (errorcheck(lastName.value)==false)
    {
        alert("Your Last Name has Invalid Characters ");
        lastName.focus();
        return false;
    }

    if (lastName.value.length>45)
    {
        alert("Name is too long");
        lastName.focus();
        return false;
    }

    if (birthOfDate.value=="")
    {
        alert ( "Please Enter Your Birth Date " );
        return false;
    }
    if (!birthOfDate.value.match(date))
    {
        alert ( "Please Enter Your Birth Date Correctly" );
        return false;
    }

    if(placeOfBirth.options[placeOfBirth.selectedIndex].value=='Egypt' && gender.options[gender.selectedIndex].value=='Male')
    {
        if(militaryStatus.value=="-1")
        {
            alert ( "Please Select your Military Status" );
            return false;
        }
    }

    if (placeOfBirth.value=="-1")
    {
        alert ( "Please Enter Your Place of Birth " );
        return false;
    }
    if(maritalStatus.value=="-1")
    {
        alert ( "Please Select your Marital Status" );
        return false;
    }

    if(maritalStatus.value!="Single")
    {

        if(numberOfChildren.value=="-1")
        {
            alert ( "Please Select The Number of Your Children" );
            return false;
        }
    }


    return true;

}

function  validate_Add_Application_Contact()
{
    var numbers=/^[0-9]+$/;
    if(document.all)
    {
        var country = document.all.Add_Applicant.elements["country_id"];
        var city = document.all.Add_Applicant.elements["city_id"];
        var address1=document.all.Add_Applicant.address1;
        var address2=document.all.Add_Applicant.address2;
        var zipCode=document.all.Add_Applicant.zip_code;
        var phone=document.all.Add_Applicant.phone;
        var mobile=document.all.Add_Applicant.mobile;

    }
    else
    {
        var country = document.Add_Applicant.elements["country_id"];
        var city = document.Add_Applicant.elements["city_id"];
        var address1=document.Add_Applicant.address1;
        var address2=document.Add_Applicant.address2;
        var zipCode=document.Add_Applicant.zip_code;
        var phone=document.Add_Applicant.phone;
        var mobile=document.Add_Applicant.mobile;
    }


    if (address1.value=="")
    {
        alert ( "Please Enter Your Address1" );
        address1.focus();
        return false;
    }

    if (errorcheck(address1.value)==false)
    {
        alert("Your Address1 has Invalid Characters \" ");
        address1.focus();
        return false;
    }

    if (address1.value.length>500)
    {
        alert ( "The Address1 is too long" );
        address1.focus();
        return false;
    }
    if (address2.value.length>500)
    {
        alert ( "Please Enter your Address2 Correctly" );
        address2.focus();
        return false;
    }
    if (errorcheck(address2.value)==false)
    {
        alert("Your Address2 has Invalid Characters");
        address2.focus();
        return false;
    }

    if (country.value=="-1")
    {
        alert ( "Please Select Your Country" );
        return false;
    }

    if(city.length>1)
    {
        if (city.value=="-1")
        {
            alert ( "Please Select Your City" );
            return false;
        }
    }
    if (zipCode.value!="")
    {
        if(!zipCode.value.match(numbers))
        {
            alert ( "Invalid Zip Code" );
            zipCode.focus();
            return false;
        }

        if(zipCode.value.length>20)
        {
            alert ("The Zip Code is too long" );
            zipCode.focus();
            return false;
        }
    }

    if ( phone.value=="")
    {
        alert ( "Please Enter Your Phone Number " );
        phone.focus();
        return false;
    }
    if (!phone.value.match(numbers))
    {
        alert ( "Invalid Phone Number " );
        phone.focus();
        return false;
    }
    
    if(phone.value.length>20)
    {
        alert("Phone Number is too long");
        phone.focus();
        return false;
    }

    if ( mobile.value=="")
    {
        alert ( "Please Enter Your Mobile " );
        mobile.focus();
        return false;
    }
    if (!mobile.value.match(numbers))
    {
        alert ( "Invalid Mobile Number" );
        mobile.focus();
        return false;
    }
    if(mobile.value.length>20)
    {
        alert ( "Mobile Number is too long" );
        mobile.focus();
        return false;
    }
    return true;

}

function  validate_Add_Application_Education()
{

    if(document.all)
    {
        var educationLevelID=document.all.Add_Applicant.elements["education_level_id"];
        var institueID=document.all.Add_Applicant.elements["institute_id"];
        var graderID=document.all.Add_Applicant.elements["grade_id"];
        var graduationYear=document.all.Add_Applicant.elements["graduation_year"];
        var studyFieldID=document.all.Add_Applicant.elements["study_field_id"];
        var yearsOfExperience=document.all.Add_Applicant.elements["years_of_experince"];
        var careerID=document.all.Add_Applicant.elements["career_id"];
        var cv =document.all.Add_Applicant.fileName;
        var company1=document.all.Add_Applicant.company1;
        var company2=document.all.Add_Applicant.company2;
        var company3=document.all.Add_Applicant.company3;
        var position1=document.all.Add_Applicant.position1;
        var position2=document.all.Add_Applicant.position2;
        var position3=document.all.Add_Applicant.position3;
        var from1=document.all.Add_Applicant.from1;
        var from2=document.all.Add_Applicant.from2;
        var from3=document.all.Add_Applicant.from3;
        var to1=document.all.Add_Applicant.to1;
        var to2=document.all.Add_Applicant.to2;
        var to3=document.all.Add_Applicant.to3;
    }
    else
    {
        var educationLevelID=document.Add_Applicant.elements["education_level_id"];
        var institueID=document.Add_Applicant.elements["institute_id"];
        var graderID=document.Add_Applicant.elements["grade_id"];
        var graduationYear=document.Add_Applicant.elements["graduation_year"];
        var studyFieldID=document.Add_Applicant.elements["study_field_id"];
        var yearsOfExperience=document.Add_Applicant.elements["years_of_experince"];
        var careerID=document.Add_Applicant.elements["career_id"];
        var cv =document.Add_Applicant.fileName;
        var company1=document.Add_Applicant.company1;
        var company2=document.Add_Applicant.company2;
        var company3=document.Add_Applicant.company3;
        var position1=document.Add_Applicant.position1;
        var position2=document.Add_Applicant.position2;
        var position3=document.Add_Applicant.position3;
        var from1=document.Add_Applicant.from1;
        var from2=document.Add_Applicant.from2;
        var from3=document.Add_Applicant.from3;
        var to1=document.Add_Applicant.to1;
        var to2=document.Add_Applicant.to2;
        var to3=document.Add_Applicant.to3;
    }

    var date=/^(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\d\d$/;

    //alert(company1.value);
    //alert(position1.value);
    //alert(from1.value);
    //alert(to1.value);
    //alert(company2.value);
    //alert(position2.value);
    //alert(from2.value);
    //alert(to2.value);
    //alert(company3.value);
    //alert(position3.value);
    //alert(from3.value);
    //alert(to3.value);
    if (educationLevelID.value=="-1")
    {
        alert ( "Please Select Your Education Level " );
        return false;
    }

    if ( institueID.value=="-1")
    {
        alert ( "Please Specify Your Institute/University " );
        return false;
    }
    if ( graderID.value=="-1")
    {
        alert ( "Please Select Your Grade " );
        return false;
    }
    if ( graduationYear.value=="-1")
    {
        alert ( "Please Select Your Graduation Year " );
        return false;
    }

    if ( studyFieldID.value=="-1")
    {
        alert ( "Please Select your Study Field" );
        return false;
    }


    if(yearsOfExperience.value!="0")
    {
        if (company1.value=="")
        {
            alert ( "Please Specify your Company" );
            company1.focus();
            return false;
        }
        if (errorcheck(company1.value)==false)
        {
            alert("Your Company Name has Invalid Character ");
            company1.focus();
            return false;
        }

        if (company1.value.length>100)
        {
            alert ( "Please Specify your Company Name correctly" );
            company1.focus();
            return false;
        }
        if (position1.value=="")
        {
            alert ( "Please Specify your Position" );
            position1.focus();
            return false;
        }
        if (errorcheck(position1.value)==false)
        {
            alert("Your Position has Invalid Character \" ");
            position1.focus();
            return false;
        }

        if (position1.value.length>100)
        {
            alert ( "Please Specify your Position correctly" );
            position1.focus();
            return false;
        }
        if (from1.value==""||!from1.value.match(date))
        {
            alert ( "Please Specify From Date using calender" );
            from1.focus();
            return false;
        }
        if (to1.value!=""&&!to1.value.match(date))
        {
            alert ( "Please Specify To Date using calender" );
            to1.focus();
            return false;
        }
    }

    if (company2.value!="")
    {
        if (errorcheck(company2.value)==false)
        {
            alert("Your Company Name has Invalid Character ");
            company2.focus();
            return false;
        }
        else if (company2.value.length>100)
        {
            alert ( "Please Specify your Company Name correctly" );
            company2.focus();
            return false;
        }
        else if (position2.value=="")
        {
            alert ( "Please Specify your Position" );
            position2.focus()
            return false;
        }
        else if (errorcheck(position2.value)==false)
        {
            alert("Invalid Character \" ");
            position2.focus();
            return false;
        }

        else  if (position2.value.length>100)
        {
            alert ( "Please Specify your Position correctly" );
            position2.focus();
            return false;
        }

        else  if (from2.value==""||!from2.value.match(date))
        {
            alert ( "Please Specify From date using calender" );
            from2.focus();
            return false;
        }
        else  if (to2.value!=""&&!to2.value.match(date))
        {
            alert ( "Please Specify To date using calender " );
            to2.focus();
            return false;
        }
    }

    else  if (company3.value!="")
    {
        if (company3.value.length>100)
        {
            alert ( "Please Specify your Company Name correctly" );
            company3.focus();
            return false;
        }

        else if (errorcheck(company3.value)==false)
        {
            alert("Your Comapny Name has Invalid Character");
            company3.focus();
            return false;
        }

        if (position3.value=="")
        {
            alert ( "Please Specify your Position" );
            position3.focus();
            return false;
        }
        else if (errorcheck(position3.value)==false)
        {
            alert("Invalid Character \" ");
            position3.focus();
            return false;
        }
        else  if (position3.value.length>100)
        {
            alert ( "Please Specify your Position correctly" );
            position3.focus();
            return false;
        }

        else  if (from3.value==""||!from3.value.match(date))
        {
            alert ( "Please Specify From date using calender" );
            from3.focus();
            return false;
        }
        else  if (to3.value!=""&&!to3.value.match(date))
        {
            alert ( "Please Specify To date using calender" );
            to3.focus();
            return false;
        }
    }
    if ( careerID.value=="-1")
    {
        alert ( "Please Select Your Career " );
        careerID.focus();
        return false;
    }

    if(cv.value == "")
    {
        alert('Please Upload your CV');
        return false;
    }
    return true;
}

function validate_Add_Application()
{
    var validPersonalData = validate_Add_Application_Personal();
    var validContactData = validate_Add_Application_Contact();
    var validEducationData = validate_Add_Application_Education();

    if(validContactData==true && validEducationData==true && validPersonalData==true )
    {
        return true;
    }
    else
    {
        return false;
    }
}

// Validate Update Application
function  validate_Update_Application_Personal()
{
    if(document.all)
    {
        var gender = document.all.Update_Applicant.elements["gender"];
        var firstName = document.all.Update_Applicant.first_name;
        var middleName =document.all.Update_Applicant.middle_name;
        var lastName =document.all.Update_Applicant.last_name;
        var birthOfDate = document.all.Update_Applicant.date_of_birth;
        var placeOfBirth = document.all.Update_Applicant.elements["place_of_birth"];
        var maritalStatus = document.all.Update_Applicant.elements["maritaly_status"];
        var militaryStatus = document.all.Update_Applicant.elements["military_status"];
        var numberOfChildren = document.all.Update_Applicant.elements["no_of_children"];
    }
    else
    {
        var gender = document.Update_Applicant.elements["gender"];
        var firstName = document.Update_Applicant.first_name;
        var middleName =document.Update_Applicant.middle_name;
        var lastName =document.Update_Applicant.last_name;
        var birthOfDate = document.Update_Applicant.date_of_birth;
        var placeOfBirth = document.Update_Applicant.elements["place_of_birth"];
        var maritalStatus = document.Update_Applicant.elements["maritaly_status"];
        var militaryStatus = document.Update_Applicant.elements["military_status"];
        var numberOfChildren = document.Update_Applicant.elements["no_of_children"];
    }

    var alpha=/^[a-zA-Z]+$/;
    var date=/^(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\d\d$/;


    if (gender.value=="-1")
    {
        alert ( "Please Specify your Gender" );
        gender.focuse();
        return false;
    }

    if (firstName.value=="")
    {
        alert ( "Please Enter Your First Name " );
        firstName.focus();
        return false;
    }

    if (!firstName.value.match(alpha))
    {
        alert ( "Please Enter Correct Name" );
        firstName.focus();
        return false;
    }

    if (errorcheck(firstName.value)==false)
    {
        alert("Your First Name has Invalid Characters");
        firstName.focus();
        return false;
    }

    if (firstName.value.length>45)
    {
        alert("Name is too long");
        firstName.focus();
        return false;
    }

    if (middleName.value=="")
    {
        alert ( "Please Enter Your Middle Name " );
        middleName.focus();
        return false;
    }


    if (!middleName.value.match(alpha))
    {
        alert ( "Please Enter Correct Name" );
        middleName.focus();
        return false;
    }
    if (errorcheck(middleName.value)==false)
    {
        alert("Your Middle Name has Invalid Characters ");
        middleName.focus();
        return false;
    }

    if (middleName.value.length>45)
    {
        alert("Name is too long");
        middleName.focus();
        return false;
    }


    if (lastName.value=="")
    {
        alert ( "Please Enter Your Last Name " );
        lastName.focus();
        return false;
    }


    if (!lastName.value.match(alpha))
    {
        alert ( "Please Enter Correct Name" );
        lastName.focus();
        return false;
    }

    if (errorcheck(lastName.value)==false)
    {
        alert("Your Last Name has Invalid Characters ");
        lastName.focus();
        return false;
    }

    if (lastName.value.length>45)
    {
        alert("Name is too long");
        lastName.focus();
        return false;
    }

    if (birthOfDate.value=="")
    {
        alert ( "Please Enter Your Birth Date " );
        return false;
    }
    if (!birthOfDate.value.match(date))
    {
        alert ( "Please Enter Your Birth Date Correctly" );
        return false;
    }

    if(placeOfBirth.options[placeOfBirth.selectedIndex].value=='Egypt' && gender.options[gender.selectedIndex].value=='Male')
    {
        if(militaryStatus.value=="-1")
        {
            alert ( "Please Select your Military Status" );
            return false;
        }
    }

    if (placeOfBirth.value=="-1")
    {
        alert ( "Please Enter Your Place of Birth " );
        return false;
    }
    if(maritalStatus.value=="-1")
    {
        alert ( "Please Select your Marital Status" );
        return false;
    }

    if(maritalStatus.value!="Single")
    {

        if(numberOfChildren.value=="-1")
        {
            alert ( "Please Select The Number of Your Children" );
            return false;
        }
    }
    return true;

}

function  validate_Update_Application_Contact()
{
    var numbers=/^[0-9]+$/;
    if(document.all)
    {
        var country = document.all.Update_Applicant.elements["country_id"];
        var city = document.all.Update_Applicant.elements["city_id"];
        var address1=document.all.Update_Applicant.address1;
        var address2=document.all.Update_Applicant.address2;
        var zipCode=document.all.Update_Applicant.zip_code;
        var phone=document.all.Update_Applicant.phone;
        var mobile=document.all.Update_Applicant.mobile;

    }
    else
    {
        var country = document.Update_Applicant.elements["country_id"];
        var city = document.Update_Applicant.elements["city_id"];
        var address1=document.Update_Applicant.address1;
        var address2=document.Update_Applicant.address2;
        var zipCode=document.Update_Applicant.zip_code;
        var phone=document.Update_Applicant.phone;
        var mobile=document.Update_Applicant.mobile;
    }

    if (address1.value=="")
    {
        alert ( "Please Enter Your Updateress1" );
        address1.focus();
        return false;
    }

    if (errorcheck(address1.value)==false)
    {
        alert("Your Updateress1 has Invalid Characters \" ");
        address1.focus();
        return false;
    }

    if (address1.value.length>500)
    {
        alert ( "The Updateress1 is too long" );
        address1.focus();
        return false;
    }
    if (address2.value.length>500)
    {
        alert ( "Please Enter your Updateress2 Correctly" );
        address2.focus();
        return false;
    }
    if (errorcheck(address2.value)==false)
    {
        alert("Your Updateress2 has Invalid Characters");
        address2.focus();
        return false;
    }

    if (country.value=="-1")
    {
        alert ( "Please Select Your Country" );
        return false;
    }

    if(city.length>1)
    {
        if (city.value=="-1")
        {
            alert ( "Please Select Your City" );
            return false;
        }
    }

    if (zipCode.value!="")
    {
        if(!zipCode.value.match(numbers))
        {
            alert ( "Invalid Zip Code" );
            zipCode.focus();
            return false;
        }

        if(zipCode.value.length>20)
        {
            alert ("The Zip Code is too long" );
            zipCode.focus();
            return false;
        }
    }

    if ( phone.value=="")
    {
        alert ( "Please Enter Your Phone Number " );
        phone.focus();
        return false;
    }
    if (!phone.value.match(numbers))
    {
        alert ( "Invalid Phone Number " );
        phone.focus();
        return false;
    }

    if(phone.value.length>20)
    {
        alert("Phone Number is too long");
        phone.focus();
        return false;
    }

    if ( mobile.value=="")
    {
        alert ( "Please Enter Your Mobile " );
        mobile.focus();
        return false;
    }
    if (!mobile.value.match(numbers))
    {
        alert ( "Invalid Mobile Number" );
        mobile.focus();
        return false;
    }
    if(mobile.value.length>20)
    {
        alert ( "Mobile Number is too long" );
        mobile.focus();
        return false;
    }
    return true;

}

function  validate_Update_Application_Education()
{

    if(document.all)
    {
        var educationLevelID=document.all.Update_Applicant.elements["education_level_id"];
        var institueID=document.all.Update_Applicant.elements["institute_id"];
        var graderID=document.all.Update_Applicant.elements["grade_id"];
        var graduationYear=document.all.Update_Applicant.elements["graduation_year"];
        var studyFieldID=document.all.Update_Applicant.elements["study_field_id"];
        var yearsOfExperience=document.all.Update_Applicant.elements["years_of_experince"];
        var careerID=document.all.Update_Applicant.elements["career_id"];
        var cv =document.all.Update_Applicant.fileName;
        var company1=document.all.Update_Applicant.company1;
        var company2=document.all.Update_Applicant.company2;
        var company3=document.all.Update_Applicant.company3;
        var position1=document.all.Update_Applicant.position1;
        var position2=document.all.Update_Applicant.position2;
        var position3=document.all.Update_Applicant.position3;
        var from1=document.all.Update_Applicant.from1;
        var from2=document.all.Update_Applicant.from2;
        var from3=document.all.Update_Applicant.from3;
        var to1=document.all.Update_Applicant.to1;
        var to2=document.all.Update_Applicant.to2;
        var to3=document.all.Update_Applicant.to3;
    }
    else
    {
        var educationLevelID=document.Update_Applicant.elements["education_level_id"];
        var institueID=document.Update_Applicant.elements["institute_id"];
        var graderID=document.Update_Applicant.elements["grade_id"];
        var graduationYear=document.Update_Applicant.elements["graduation_year"];
        var studyFieldID=document.Update_Applicant.elements["study_field_id"];
        var yearsOfExperience=document.Update_Applicant.elements["years_of_experince"];
        var careerID=document.Update_Applicant.elements["career_id"];
        var cv =document.Update_Applicant.fileName;
        var company1=document.Update_Applicant.company1;
        var company2=document.Update_Applicant.company2;
        var company3=document.Update_Applicant.company3;
        var position1=document.Update_Applicant.position1;
        var position2=document.Update_Applicant.position2;
        var position3=document.Update_Applicant.position3;
        var from1=document.Update_Applicant.from1;
        var from2=document.Update_Applicant.from2;
        var from3=document.Update_Applicant.from3;
        var to1=document.Update_Applicant.to1;
        var to2=document.Update_Applicant.to2;
        var to3=document.Update_Applicant.to3;
    }


    var date=/^(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\d\d$/;


    if (educationLevelID.value=="-1")
    {
        alert ( "Please Select Your Education Level " );
        return false;
    }

    if ( institueID.value=="-1")
    {
        alert ( "Please Specify Your Institute/University " );
        return false;
    }
    if ( graderID.value=="-1")
    {
        alert ( "Please Select Your Grade " );
        return false;
    }
    if ( graduationYear.value=="-1")
    {
        alert ( "Please Select Your Graduation Year " );
        return false;
    }

    if ( studyFieldID.value=="-1")
    {
        alert ( "Please Select your Study Field" );
        return false;
    }


    if(yearsOfExperience.value!="0")
    {
        if (company1.value=="")
        {
            alert ( "Please Specify your Company" );
            company1.focus();
            return false;
        }
        if (errorcheck(company1.value)==false)
        {
            alert("Your Company Name has Invalid Character ");
            company1.focus();
            return false;
        }

        if (company1.value.length>100)
        {
            alert ( "Please Specify your Company Name correctly" );
            company1.focus();
            return false;
        }
        if (position1.value=="")
        {
            alert ( "Please Specify your Position" );
            position1.focus();
            return false;
        }
        if (errorcheck(position1.value)==false)
        {
            alert("Your Position has Invalid Character \" ");
            position1.focus();
            return false;
        }

        if (position1.value.length>100)
        {
            alert ( "Please Specify your Position correctly" );
            position1.focus();
            return false;
        }
        if (from1.value==""||!from1.value.match(date))
        {
            alert ( "Please Specify From Date using calender" );
            from1.focus();
            return false;
        }
        if (to1.value!=""&&!to1.value.match(date))
        {
            alert ( "Please Specify To Date using calender" );
            to1.focus();
            return false;
        }
    }

    if (company2.value!="")
    {
        if (errorcheck(company2.value)==false)
        {
            alert("Your Company Name has Invalid Character ");
            company2.focus();
            return false;
        }
        else if (company2.value.length>100)
        {
            alert ( "Please Specify your Company Name correctly" );
            company2.focus();
            return false;
        }
        else if (position2.value=="")
        {
            alert ( "Please Specify your Position" );
            position2.focus()
            return false;
        }
        else if (errorcheck(position2.value)==false)
        {
            alert("Invalid Character \" ");
            position2.focus();
            return false;
        }

        else  if (position2.value.length>100)
        {
            alert ( "Please Specify your Position correctly" );
            position2.focus();
            return false;
        }

        else  if (from2.value==""||!from2.value.match(date))
        {
            alert ( "Please Specify From date using calender" );
            from2.focus();
            return false;
        }
        else  if (to2.value!=""&&!to2.value.match(date))
        {
            alert ( "Please Specify To date using calender " );
            to2.focus();
            return false;
        }
    }

    else  if (company3.value!="")
    {
        if (company3.value.length>100)
        {
            alert ( "Please Specify your Company Name correctly" );
            company3.focus();
            return false;
        }

        else if (errorcheck(company3.value)==false)
        {
            alert("Your Comapny Name has Invalid Character");
            company3.focus();
            return false;
        }

        if (position3.value=="")
        {
            alert ( "Please Specify your Position" );
            position3.focus();
            return false;
        }
        else if (errorcheck(position3.value)==false)
        {
            alert("Invalid Character \" ");
            position3.focus();
            return false;
        }
        else  if (position3.value.length>100)
        {
            alert ( "Please Specify your Position correctly" );
            position3.focus();
            return false;
        }

        else  if (from3.value==""||!from3.value.match(date))
        {
            alert ( "Please Specify From date using calender" );
            from3.focus();
            return false;
        }
        else  if (to3.value!=""&&!to3.value.match(date))
        {
            alert ( "Please Specify To date using calender" );
            to3.focus();
            return false;
        }
    }
    if ( careerID.value=="-1")
    {
        alert ( "Please Select Your Career " );
        careerID.focus();
        return false;
    }

    if(cv.value == "")
    {
        alert('Please Upload your CV');
        return false;
    }
    return true;
}

function validate_Update_Application()
{
    var validPersonalData = validate_Update_Application_Personal();
    var validContactData = validate_Update_Application_Contact();
    var validEducationData = validate_Update_Application_Education();

    if(validContactData==true && validEducationData==true && validPersonalData==true )
    {
        return true;
    }
    else
    {
        return false;
    }
}

function add_Application_Marital_Changed()
{
    if(document.all) //Internt Explorer
    {
        var maritalyStatusCombo =document.all.Add_Applicant.elements["maritaly_status"];
        var childrenNumber =document.all.Add_Applicant.elements["no_of_children"];
        if((maritalyStatusCombo.options[maritalyStatusCombo.selectedIndex].value!='Single')&&(maritalyStatusCombo.options[maritalyStatusCombo.selectedIndex].value!='-1'))
        {
            document.all.childrenCombo.style.visibility = 'visible';
            document.all.childrenCell.style.visibility = 'visible';
        }
        else
        {
            document.all.childrenCombo.style.visibility = 'hidden';
            document.all.childrenCell.style.visibility= 'hidden';
            childrenNumber.options[0].selected = true;
        }
    }

    else  //(document.getElementById)  Firefox
    {
        var maritalyStatusCombo =document.Add_Applicant.elements["maritaly_status"];
        var childrenNumber =document.Add_Applicant.elements["no_of_children"];
        if((maritalyStatusCombo.options[maritalyStatusCombo.selectedIndex].value!='Single')&&(maritalyStatusCombo.options[maritalyStatusCombo.selectedIndex].value!='-1'))
        {
            document.getElementById('no_of_children').style.visibility = 'visible';
            document.getElementById('childrenCell').style.visibility = 'visible';
        }
        else
        {
            document.getElementById('no_of_children').style.visibility = 'hidden';
            document.getElementById('childrenCell').style.visibility = 'hidden';
            childrenNumber.options[0].selected = true;
        }
    }
}

function update_Application_Marital_Changed()
{
    if(document.all) //Internt Explorer
    {
        var maritalyStatusCombo =document.all.Update_Applicant.elements["maritaly_status"];
        var childrenNumber =document.all.Update_Applicant.elements["no_of_children"];
        if((maritalyStatusCombo.options[maritalyStatusCombo.selectedIndex].value!='Single')&&(maritalyStatusCombo.options[maritalyStatusCombo.selectedIndex].value!='-1'))
        {
            document.all.childrenCombo.style.visibility = 'visible';
            document.all.childrenCell.style.visibility = 'visible';
        }
        else
        {
            document.all.childrenCombo.style.visibility = 'hidden';
            document.all.childrenCell.style.visibility= 'hidden';
            childrenNumber.options[0].selected = true;
        }
    }

    else  //(document.getElementById)  Firefox
    {
        var maritalyStatusCombo =document.Update_Applicant.elements["maritaly_status"];
        var childrenNumber =document.Update_Applicant.elements["no_of_children"];
        if((maritalyStatusCombo.options[maritalyStatusCombo.selectedIndex].value!='Single')&&(maritalyStatusCombo.options[maritalyStatusCombo.selectedIndex].value!='-1'))
        {
            document.getElementById('no_of_children').style.visibility = 'visible';
            document.getElementById('childrenCell').style.visibility = 'visible';
        }
        else
        {
            document.getElementById('no_of_children').style.visibility = 'hidden';
            document.getElementById('childrenCell').style.visibility = 'hidden';
            childrenNumber.options[0].selected = true;
        }
    }
}

function add_Application_Nationality_Changed()
{
    if(document.all)     //Internt Explorer
    {
        var placeOfBirthCombo =document.all.Add_Applicant.elements["place_of_birth"];
        var genderCombo =document.all.Add_Applicant.elements["gender"];
        var militaryStatus =document.all.Add_Applicant.elements["military_status"];
        if(placeOfBirthCombo.options[placeOfBirthCombo.selectedIndex].value=='67' && genderCombo.options[genderCombo.selectedIndex].value=='Male')
        {
            document.all.military_status.style.visibility = "visible";
            document.all.malitaryCell.style.visibility = 'visible';
        }
        else
        {
            document.all.military_status.style.visibility= "hidden";
            document.all.malitaryCell.style.visibility = 'hidden';
        }
        militaryStatus.options[0].selected = true;
    }
    else
    {
        if(document.getElementById)  // Firefox
        {
            var placeOfBirthCombo =document.Add_Applicant.elements["place_of_birth"];
            var genderCombo =document.Add_Applicant.elements["gender"];
            var militaryStatus =document.Add_Applicant.elements["military_status"];

            if(placeOfBirthCombo.options[placeOfBirthCombo.selectedIndex].value=='67' && genderCombo.options[genderCombo.selectedIndex].value=='Male')
            {
                document.getElementById('military_status').style.visibility = 'visible';
                document.getElementById('malitaryCell').style.visibility = 'visible';
            }
            else
            {
                document.getElementById('military_status').style.visibility = 'hidden';
                document.getElementById('malitaryCell').style.visibility = 'hidden';
            }
            militaryStatus.options[0].selected = true;
        }
    }
    
}

function update_Application_Nationality_Changed()
{
    if(document.all)     //Internt Explorer
    {
        var placeOfBirthCombo =document.all.Update_Applicant.elements["place_of_birth"];
        var genderCombo =document.all.Update_Applicant.elements["gender"];
        var militaryStatus =document.Update_Applicant.elements["military_status"];
        if(placeOfBirthCombo.options[placeOfBirthCombo.selectedIndex].value=='67' && genderCombo.options[genderCombo.selectedIndex].value=='Male')
        {
            document.all.military_status.style.visibility = "visible";
            document.all.malitaryCell.style.visibility = 'visible';
        }
        else
        {
            document.all.military_status.style.visibility= "hidden";
            document.all.malitaryCell.style.visibility = 'hidden';
        }
        militaryStatus.options[0].selected = true;
    }
    else
    {
        if(document.getElementById)  // Firefox
        {
            var placeOfBirthCombo =document.Update_Applicant.elements["place_of_birth"];
            var genderCombo =document.Update_Applicant.elements["gender"];
            var militaryStatus =document.Update_Applicant.elements["military_status"];

            if(placeOfBirthCombo.options[placeOfBirthCombo.selectedIndex].value=='67' && genderCombo.options[genderCombo.selectedIndex].value=='Male')
            {
                document.getElementById('military_status').style.visibility = 'visible';
                document.getElementById('malitaryCell').style.visibility = 'visible';
            }
            else
            {
                document.getElementById('military_status').style.visibility = 'hidden';
                document.getElementById('malitaryCell').style.visibility = 'hidden';
            }
            militaryStatus.options[0].selected = true;
        }
    }

}


function  validate_Login()
{
    var check_Email =document.Login.user_email;
    var check_password =document.Login.user_password;
    check_Email.value=check_Email.value.trim();
    check_password.value=check_password.value.trim();

    if (check_Email.value=="")
    {
        alert ( "Please Enter Your Email" );
        check_Email.focus();
        return false;
    }
    if (errorcheck(check_Email.value)==false)
    {
        alert("Invalid Character \" ");
        check_Email.focus();
        return false;
    }

    if (check_Email.value.length>100)
    {
        alert("Email is too long");
        check_Email.focus();
        return false;
    }

    if (echeck(check_Email.value)==false)
    {
        check_Email.focus();
        return false;
    }

    if (check_password.value=="")
    {
        alert ( "Please Enter Your Password" );
        check_password.focus();
        return false;
    }
    if (errorcheck(check_password.value)==false)
    {
        alert("Invalid Character \" ");
        check_password.focus();
        return false;
    }
    if (check_password.value.length<6)
    {
        alert("Password shouldn't be less than 6 characters ");
        check_password.focus();
        return false;
    }
    if (check_password.value.length>45)
    {
        alert("Password is too long ");
        check_password.focus();
        return false;
    }
    return true;
}

function  validate_Registeration()
{
    if(document.all)
    {
        var userName =document.all.Add_User.user_name;
        var userEmail =document.all.Add_User.user_email;
        var userPassword =document.all.Add_User.user_password;
        var userPassword2 =document.all.Add_User.user_password2;
        var question =document.all.Add_User.elements["question"];
        var answer =document.all.Add_User.answer;
        var userType =document.all.Add_User.elements["user_type"];
    }
    else
    {
        var userName =document.Add_User.user_name;
        var userEmail =document.Add_User.user_email;
        var userPassword =document.Add_User.user_password;
        var userPassword2 =document.Add_User.user_password2;
        var question =document.Add_User.elements["question"];
        var answer =document.Add_User.answer;
        var userType =document.Add_User.elements["user_type"];
    }
    var alpha=/^[a-zA-Z]+$/;
    userName.value=userName.value.trim();
    userEmail.value=userEmail.value.trim();
    userPassword.value=userPassword.value.trim();
    userPassword2.value=userPassword2.value.trim();
    answer.value=answer.value.trim();
    if (userName.value=="")
    {
        alert ( "Please Enter Your Name " );
        userName.focus();
        return false;
    }

    if (!userName.value.match(alpha))
    {
        alert ( "Please Enter Correct Name" );
        userName.focus();
        return false;
    }

    if (errorcheck(userName.value)==false)
    {
        alert("Please Enter Valid User Name");
        userEmail.focus();
        return false;
    }

    if (userName.value.length>45)
    {
        alert("User Name is too long");
        userName.focus();
        return false;
    }

    if (userEmail.value=="")
    {
        alert ( "Please Enter Your Email" );
        userEmail.focus();
        return false;
    }
    if(echeck(userEmail.value)==false)
    {
        userEmail.focus();
        return false;
    }

    if(userEmail.value.length>100)
    {
        alert("Email is too long");
        userEmail.focus();
        return false;
    }

    if(userPassword.value=="")
    {
        alert ( "Please Enter Your Password" );
        userPassword.focus();
        return false;
    }
    if (errorcheck(userPassword.value)==false)
    {
        alert("Please Enter Valid Password");
        userPassword.focus();
        return false;
    }
    if (userPassword.value.length<6)
    {
        alert("Password shouldn't be less than 6 characters ");
        userPassword.focus();
        return false;
    }
    if (userPassword.value.length>45)
    {
        alert("Password is too long ");
        userPassword.focus();
        return false;
    }

    if (userPassword2.value=="")
    {
        alert ( "Please Confirm Your Password" );
        userPassword2.focus();
        return false;
    }
    if (errorcheck(userPassword2.value)==false)
    {
        alert("Invalid Character \" ");
        userPassword2.focus();
        return false;
    }
    if(userPassword2.value.length<6)
    {
        alert("Password shouldn't be less than 6 characters ");
        userPassword2.focus();
        return false;
    }
    if (userPassword2.value.length>45)
    {
        alert("Password is too long ");
        userPassword2.focus();
        return false;
    }

    if (userPassword.value!=userPassword2.value)
    {
        alert ( "You must enter the same password in the password and confirm password fields" );

        userPassword2.focus();
        return false;
    }

    if (question.value=="Please Select One")
    {
        alert ( "Please Choose a Question" );
        return false;
    }

    if (answer.value=="")
    {
        alert ( "Please Enter Answer " );
        answer.focus();
        return false;
    }

    if (errorcheck(answer.value)==false)
    {
        alert("Invalid Character \" ");
        answer.focus();
        return false;
    }

    if (answer.value.length>100)
    {
        alert("Answer is too long");
        answer.focus();
        return false;
    }


    if (userType.value=="-1")
    {
        alert ( "Please Choose type" );
        return false;
    }
    return true;
}

